# Maintainer: Stuart Cardall <developer@it-offshore.co.uk>
# Contributor: Bartłomiej Piotrowski <bpiotrowski@alpinelinux.org>
# Contributor: Pedro Filipe <xpecex@outlook.com>
pkgname=zram-init
pkgver=11.1
pkgrel=1
pkgdesc="wrapper script for the zram kernel module"
arch="noarch"
url="https://github.com/vaeth/zram-init"
license="GPL-2.0-only"
depends="e2fsprogs-extra util-linux-misc" # we need zramctl from util-linux-misc
subpackages="
	$pkgname-zsh-completion:zshcomp
	$pkgname-openrc
	$pkgname-doc
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/vaeth/zram-init/archive/v$pkgver.tar.gz
	"
options="!check" # no tests

build() {
	make SYSTEMD=FALSE SYSCONFDIR=/etc GETTEXT=FALSE
}

package() {
	install -Dm644 modprobe.d/zram.conf "$pkgdir"/lib/modprobe.d/zram.conf
	install -Dm755 sbin/zram-init "$pkgdir"/usr/sbin/zram-init

	install -Dm644 openrc/conf.d/zram-init "$pkgdir"/etc/conf.d/zram-init
	install -Dm755 openrc/init.d/zram-init "$pkgdir"/etc/init.d/zram-init

	install -Dm644 man/zram-init.8 -t "$pkgdir"/usr/share/man/man8
}

zshcomp() {
	depends=""
	pkgdesc="Zsh completions for $pkgname"
	install_if="$pkgname=$pkgver-r$pkgrel zsh"

	install -Dm644 "$builddir"/zsh/_zram-init -t "$subpkgdir"/usr/share/zsh/site-functions
}

sha512sums="
dcbfe9bb085e1bb1856f53fb5722fc008a8b7b8099423be174f02fcaa4093c19e24c33f08deeec9d1525b9512b7c5640c4ac396c60f7b6016b56edeb38a64285  zram-init-11.1.tar.gz
"
